package PlaneWar;

import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;

public class Main extends JPanel {
  public static BufferedImage picBee;
  public static BufferedImage picBigPlane;
  public static BufferedImage picenemyPlane;
  static {
      try {
          picBee = ImageIO.read(Main.class.getResourceAsStream("pic/bee.png"));
      } catch (IOException e) {
          e.printStackTrace();
      }

      try {
          picBigPlane = ImageIO.read(Main.class.getResourceAsStream("pic/bigplane.png"));
      } catch (IOException e) {
          e.printStackTrace();
      }

      try {
          picenemyPlane = ImageIO.read(Main.class.getResourceAsStream("pic/extraplane_n1.png"));
      } catch (IOException e) {
          e.printStackTrace();
      }


  }

    //创建蜜蜂对象
    Bee Bee01 = new Bee();
    bigPlane bigPlane01 = new bigPlane();
    enemyPlane enemyPlane01 = new enemyPlane();
    @Override
    public void paint(Graphics g) {
        super.paint(g);
        g.drawImage(Bee01.img,Bee01.x,Bee01.y,this);
        g.drawImage(bigPlane01.img,bigPlane01.x,bigPlane01.y,this);
        g.drawImage(enemyPlane01.img,enemyPlane01.x,enemyPlane01.y,this);
    }

    public static void main(String[] args) {
        //创建窗口
        JFrame win = new JFrame("飞机大战");
        //设置窗口大小
        win.setSize(200,400);
        //将画板添加到窗口
        Main min = new Main();
        win.add(min);
        //设置窗口在点击关闭时，自动将程序关闭
        win.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
        //设置窗口可视化
        win.setVisible(true);



    }
}
